<?php
/**
	Sponsor Manager (sponsors.php file)
    Copyright (C) <Fri Apr 11 06:34:47 CEST 2008>  Marcos Ramírez <marcosramirez@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    
    Purpose:
    Last Modified:
**/

global $sponsors;
global $promos;
global $html;
global $sm;
if ($_POST['name'] && $_POST['url'] && $_POST['affiliateid'])
	$sponsors->addSponsor($_POST['url'], $_POST['name'], $_POST['affiliateid']);


$html->addCSSFile('sponsors.css');
$html->addJSFile('sponsors.js');
$html->header();
?>
<p><a href="#" id="clickAddSponsor">Add Sponsor</a></p>
<div id="addSponsor">
<form method="post" action="<?php echo $Cfg['Sys']['webDir'].'?section=Sponsors'; ?>">
Url: <input name="url" type="text" /><br />
Name:<input name="name" type="text" /><br />
Affiliate ID:<input name="affiliateid" type="text" /><br />
<input type="submit" value="<?php echo _('Submit Sponsor');?>">
</form>

</div>

<?php

echo '<table><tr><td>Sponsor</td><td>Promotions</td></tr>';
$result=$sm->Query("SELECT sponsorid,url,name,affiliateid FROM My_Sponsors");
while ($Res=$sm->Fetch($result)) {
	echo '<tr><td>'.$Res['name'].' ('.$Res['affiliateid'].')</td><td>'.$promos->totalPromotionalContentFromSponsor($Res['sponsorid']).'</td></tr>';
}
echo '</table>';

$html->footer();

?>